#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <list>
#include <string>
#include <cmath>
#include <bitset>
#include <stack>
#include <unordered_set>
#include <math.h>
#include <functional>
#include<unordered_map>
#include<iomanip>

#define ull             unsigned long long 
#define ll              long long
#define pii             pair<ll ,ll>
#define ft              first
#define sd              second
#define cy              cout<<"YES"<<endl
#define cn              cout<<"NO"<<endl
#define forn(i,n)       for(ll (i)=0;(i)<(n);(i)++)   
#define forne(i,n)      for(ll (i)=1;(i)<=(n);(i)++)
#define rforn(i,n)      for(ll (i)=(n-1);i>=0;i--)
#define rforne(i,n)     for(ll (i)=n;i>=1;i--)
#define vv              vector
#define inf             1e9
const int N = 4e5 + 100;
const int mod = 1e9 + 7;
ll T;

inline void write(int x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x >= 10)
	{
		write(x / 10);
	}
	putchar(x % 10 + '0');
}


void solve()
{

	double n; cin >> n;
	vv<ll>nums(n);
	forn(i, n)
		cin >> nums[i];
	if (n >= 63) {
		ll sum = 0;
		forn(i, n)
			sum += nums[i];
		cout << sum - n << endl;
		return;
	}
	sort(nums.begin(), nums.end());

	ll up = pow(nums[n - 1], 1 / (n - 1)) + 1;
	ll ans = INT64_MAX;
	for (ull i = 1; i <= up; i++) {
		ll exp = 1;
		ll sum = 0;
		forn(j, n)
		{
			sum += (abs(nums[j] - exp));
			exp *= i;
		}
		ans = min(ans, sum);
	}
	write(ans);
}
int main() {

	T = 1;
	//cin >> T;
	while (T--)
		solve();
}